package com.ssy.lingxi.after.sale.config;

import org.hibernate.dialect.PostgreSQL95Dialect;

/**
 * 配置关联实体不生成外键
 * <p>要在application.yml里面的spring.jpa.database-platform中设置</p>
 *
 * @author 万宁
 * @version 2.0.0
 * @date 2020-06-12
 */
public class PostgreSQLWithoutForeignKeys95Dialect extends PostgreSQL95Dialect {
    @Override
    public String getAddForeignKeyConstraintString(
            String constraintName,
            String[] foreignKey,
            String referencedTable,
            String[] primaryKey,
            boolean referencesPrimaryKey) {
        //设置foreignkey对应的列值可以为空
        return " alter "+ foreignKey[0] +" set default null " ;
    }
}
